
import vtk

# 创建点数据（这里用随机点作为示例）
points = vtk.vtkPoints()
for i in range(100):
    points.InsertNextPoint(
        vtk.vtkMath.Random(-1, 1),
        vtk.vtkMath.Random(-1, 1),
        vtk.vtkMath.Random(-1, 1)
    )

# 创建多边形数据
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)

# 创建高斯溅射过滤器
splatter = vtk.vtkGaussianSplatter()
splatter.SetInputData(polydata)
splatter.SetSampleDimensions(50, 50, 50)  # 设置输出体积的维度
splatter.SetRadius(0.1)  # 设置高斯核的半径
splatter.SetExponentFactor(2.0)  # 设置指数因子
splatter.Update()

# 后续可以添加等值面提取等步骤
contour = vtk.vtkContourFilter()
contour.SetInputConnection(splatter.GetOutputPort())
contour.SetValue(0, 0.01)

# 创建映射器和演员
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(contour.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

# 创建渲染器、渲染窗口等
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)

render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)

render_window.Render()
interactor.Start()